#include"mainwidget.h"
#include"gamewidge.h"
#include<QWidget>
#include<QVBoxLayout>
#include<QIcon>
#include<QBrush>
#include<QLabel>
#include<QPushButton>

mainWidget::mainWidget(QWidget *parent)
    : QWidget(parent)
{
    this->setFixedSize(800,417);
    this->setWindowTitle("STAR WARS");
    this->setWindowIcon(QIcon("img/DS.png"));

    QPalette palette;
    palette.setBrush(QPalette::Background,QBrush(QPixmap("img/BG.png")));
    this->setPalette(palette);


    this->lable=new QLabel(this);
    lable->setPixmap(QPixmap("img/ST.png"));

    this->startbtn=new QPushButton(this);
    this->startbtn->setIcon(QIcon("img/start.png"));
    this->startbtn->setIconSize(QSize(141,41));
    this->startbtn->setFlat(true);
    this->startbtn->setFocusPolicy(Qt::NoFocus);

    this->setbtn=new QPushButton(this);
    this->setbtn->setIcon(QIcon("img/set.png"));
    this->setbtn->setIconSize(QSize(141,41));
    this->setbtn->setFlat(true);
    this->setbtn->setFocusPolicy(Qt::NoFocus);

    this->helpbtn=new QPushButton(this);
    this->helpbtn->setIcon(QIcon("img/help.png"));
    this->helpbtn->setIconSize(QSize(141,41));
    this->helpbtn->setFlat(true);
    this->helpbtn->setFocusPolicy(Qt::NoFocus);


    this->quitbtn=new QPushButton(this);
    this->quitbtn->setIcon(QIcon("img/quit.png"));
    this->quitbtn->setIconSize(QSize(141,41));
    this->quitbtn->setFlat(true);
    this->quitbtn->setFocusPolicy(Qt::NoFocus);

    this->vboxlayout=new QVBoxLayout(this);
    this->vboxlayout->addWidget(lable);
    this->vboxlayout->addWidget(startbtn);
    this->vboxlayout->addWidget(setbtn);
    this->vboxlayout->addWidget(quitbtn);
    this->vboxlayout->addWidget(helpbtn);
    this->vboxlayout->setAlignment(Qt::AlignCenter);


    gamew=new gamewidge(this);
    gamew->hide();


    this->connect(startbtn,SIGNAL(clicked()),this,SLOT(startbtnclick()));

    this->connect(quitbtn,SIGNAL(clicked()),this,SLOT(quitbtnclick()));
}

mainWidget::~mainWidget()
{
}

void mainWidget::startbtnclick()
{
    gamew->show();
}

void mainWidget::quitbtnclick()
{
    this->close();
    exit(0);
}

